﻿using System;

class NumberCounting
{
    static void Main()
    {
        int[] array = { 2, 6, 1, 2, -4, 2, 15, 6, 0, 0, 9, 1 };

        // Printing the array on the console
        for (int i = 0; i < array.Length; i++)
        {
            Console.WriteLine("[{0,2}] = {1,2}", i, array[i]);
        }

        Console.WriteLine();

        int searchedNumber = 2;

        int numRepetitions = FindRepetition(array, searchedNumber);

        Console.WriteLine("The number \"{0}\" is found {1} times in the array.", searchedNumber, numRepetitions);
    }

    static int FindRepetition(int[] array, int target)
    {
        int repetitions = 0;

        for (int i = 0; i < array.Length; i++)
        {
            if (array[i] == target)
            {
                repetitions++;
            }
        }

        return repetitions;
    }
}
